home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / CBGRX103.ZIP / contrib / libgrx / test / colorops.c < prev    next >
Text File  |  1993-12-06  |  4KB  |  126 lines

  1. /**
  2.  ** COLOROPS.C
  3.  **
  4.  **  Copyright (C) 1992, Csaba Biegl
  5.  **    820 Stirrup Dr, Nashville, TN, 37221
  6.  **    csaba@vuse.vanderbilt.edu
  7.  **
  8.  **  This file is distributed under the terms listed in the document
  9.  **  "copying.cb", available from the author at the address above.
  10.  **  A copy of "copying.cb" should accompany this file; if not, a copy
  11.  **  should be available from where this file was obtained.  This file
  12.  **  may not be distributed without a verbatim copy of "copying.cb".
  13.  **  You should also have received a copy of the GNU General Public
  14.  **  License along with this program (it is in the file "copying");
  15.  **  if not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  16.  **  Cambridge, MA 02139, USA.
  17.  **
  18.  **  This program is distributed in the hope that it will be useful,
  19.  **  but WITHOUT ANY WARRANTY; without even the implied warranty of
  20.  **  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21.  **  GNU General Public License for more details.
  22.  **/
  23.  
  24.  
  25. #include "test.h"
  26.  
  27. TESTFUNC(colorops)
  28. {
  29.     int x = GrSizeX();
  30.     int y = GrSizeY();
  31.     int ww = (x * 2) / 3;
  32.     int wh = (y * 2) / 3;
  33.     int c,ii,jj,bg;
  34.     GrFBoxColors bcolors,ocolors,icolors;
  35.     int wdt = ww / 150;
  36.     int bw = x / 16;
  37.     int bh = y / 16;
  38.     int bx,by;
  39.  
  40.     GrSetRGBcolorMode();
  41.  
  42.     bcolors.fbx_intcolor = GrAllocColor(160,100,30);
  43.     bcolors.fbx_topcolor = GrAllocColor(240,150,45);
  44.     bcolors.fbx_leftcolor = GrAllocColor(240,150,45);
  45.     bcolors.fbx_rightcolor = GrAllocColor(80,50,15);
  46.     bcolors.fbx_bottomcolor = GrAllocColor(80,50,15);
  47.  
  48.     ocolors.fbx_intcolor = GrAllocColor(0,120,100);
  49.     ocolors.fbx_topcolor = GrAllocColor(0,180,150);
  50.     ocolors.fbx_leftcolor = GrAllocColor(0,180,150);
  51.     ocolors.fbx_rightcolor = GrAllocColor(0,90,60);
  52.     ocolors.fbx_bottomcolor = GrAllocColor(0,90,60);
  53.  
  54.     icolors.fbx_intcolor = GrAllocColor(30,30,30);
  55.     icolors.fbx_bottomcolor = GrAllocColor(0,180,150);
  56.     icolors.fbx_rightcolor = GrAllocColor(0,180,150);
  57.     icolors.fbx_leftcolor = GrAllocColor(0,90,60);
  58.     icolors.fbx_topcolor = GrAllocColor(0,90,60);
  59.  
  60.     c = GrAllocColor(250,250,0);
  61.     bg = GrNOCOLOR;
  62.  
  63.     for(ii = 0,by = -(bh / 3); ii < 17; ii++) {
  64.         for(jj = 0,bx = (-bw / 2); jj < 17; jj++) {
  65.         GrFramedBox(bx+2*wdt,by+2*wdt,bx+bw-2*wdt-1,by+bh-2*wdt-1,2*wdt,&bcolors);
  66.         bx += bw;
  67.         }
  68.         by += bh;
  69.     }
  70.  
  71.     GrFramedBox(ww/4-5*wdt-1,wh/4-5*wdt-1,ww/4+5*wdt+ww+1,wh/4+5*wdt+wh+1,wdt,&ocolors);
  72.     GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors);
  73.  
  74.     GrSetClipBox(ww/4,wh/4,ww/4+ww,wh/4+wh);
  75.  
  76.     drawing(ww/4,wh/4,ww,wh,c,bg);
  77.     while(!kbhit()) {
  78.         drawing(ww/4+(random()%100),
  79.         wh/4+(random()%100),
  80.         ww,
  81.         wh,
  82.         ((random() / 16) & (GrNumColors() - 1)),
  83.         bg
  84.         );
  85.     }
  86.     getkey();
  87.     GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors);
  88.     drawing(ww/4,wh/4,ww,wh,c,bg);
  89.     while(!kbhit()) {
  90.         drawing(ww/4+(random()%100),
  91.         wh/4+(random()%100),
  92.         ww,
  93.         wh,
  94.         ((random() / 16) & (GrNumColors() - 1)) | GrXOR,
  95.         bg
  96.         );
  97.     }
  98.     getkey();
  99.     GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors);
  100.     drawing(ww/4,wh/4,ww,wh,c,bg);
  101.     while(!kbhit()) {
  102.         drawing(ww/4+(random()%100),
  103.         wh/4+(random()%100),
  104.         ww,
  105.         wh,
  106.         ((random() / 16) & (GrNumColors() - 1)) | GrOR,
  107.         bg
  108.         );
  109.     }
  110.     getkey();
  111.     GrFramedBox(ww/4-1,wh/4-1,ww/4+ww+1,wh/4+wh+1,wdt,&icolors);
  112.     drawing(ww/4,wh/4,ww,wh,c,bg);
  113.     while(!kbhit()) {
  114.         drawing(ww/4+(random()%100),
  115.         wh/4+(random()%100),
  116.         ww,
  117.         wh,
  118.         ((random() / 16) & (GrNumColors() - 1)) | GrAND,
  119.         bg
  120.         );
  121.     }
  122.     getkey();
  123.  
  124. }
  125.  
  126.